
///
/// This class handles the connection between the client and the server stub
/// allocated to the client
///

#ifndef HANDLER_H
#define HANDLER_H

#include "common.h"
#include <string>

class Handler
{

public:
	
	Handler() {}

	Handler(int fd, std::string& fileName, struct sockaddr_storage clientAddr,
				socklen_t clientAddrSize);

	Handler(const Handler& rhs);
	Handler& operator=(const Handler& copy);

	int HandleMessage(const char *packet, const unsigned int packetLength);
	int initial(std::string fileName, sockaddr_storage clientAddr,socklen_t clientAddrSize);

private:

	int ActOnMessage();
	int fin;
	int mSockFD;
	int previous_block;
	int next_block;
	
	char mMsgBuf[MSG_BUF_SIZE];

	std::string mFileName;

	struct sockaddr_storage mClientAddr;
	socklen_t mClientAddrSize;

	//unsigned int mMsgBufPtr;

	//unsigned int mMsgLength;
};

#endif
